/**
  ******************************************************************************
  * @file           : SymmetricEncryption.h
  * @author         : sally
  * @brief          : None
  * @attention      : None
  * @date           : 24-11-11
  ******************************************************************************
  */


#ifndef SYMMETRICENCRYPTION_H
#define SYMMETRICENCRYPTION_H

#include <cstddef>
#include <cstring>
#include <iostream>
#include <openssl/rand.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

namespace droneswarm
{
    class SymmetricEncryption
    {
    public:
        SymmetricEncryption();
        ~SymmetricEncryption();
        void setSymmeticKey(unsigned char* symmeticKey);
        unsigned char* getIv() { return iv_; }
        void setIv() { RAND_bytes(iv_, 16); }
        void setIv(unsigned char* receivedIv) { memcpy(iv_, receivedIv, 16); }
        bool aes_Encryption(const unsigned char* plainText, int plainTextLen, unsigned char* cipherText,
                            int* cipherTextLen);
        bool aes_Decryption(const unsigned char* cipherText, int cipherTextLen, unsigned char* plainText,
                            int* plainTextLen);

    private:
        unsigned char* symmeticKey_;
        unsigned char* iv_; //初始化向量，用于为加密过程提供一个随机或伪随机的起点。
    };
} // namespace droneswarm

#endif //SYMMETRICENCRYPTION_H
